//
//  BezierToForward.cpp
//  client
//
//  Created by DuanHongbo on 15/1/29.
//
//

#include "BezierToForward.h"


BezierToForward* BezierToForward::create(float duration, const ccBezierConfig& c,bool autoHeadOn , float initAngle )
{
    BezierToForward *bezierTo = new (std::nothrow) BezierToForward();
    bezierTo->initWithDuration(duration, c,autoHeadOn,initAngle);
    bezierTo->autorelease();
    
    return bezierTo;
}

bool BezierToForward::initWithDuration(float duration, const ccBezierConfig& c,bool autoHeadOn , float initAngle )
{
    if (BezierByForward::initWithDuration(duration,c,autoHeadOn,initAngle))
    {
        _toConfig = c;
        return true;
    }
    
    return false;
}

BezierToForward* BezierToForward::clone() const
{
    // no copy constructor
    auto a = new (std::nothrow) BezierToForward();
    a->initWithDuration(_duration, _toConfig,m_autoHeadOn,m_initAngle);
    a->autorelease();
    return a;
}

void BezierToForward::startWithTarget(Node *target)
{
    BezierByForward::startWithTarget(target);
    _config.controlPoint_1 = _toConfig.controlPoint_1 - _startPosition;
    _config.controlPoint_2 = _toConfig.controlPoint_2 - _startPosition;
    _config.endPosition = _toConfig.endPosition - _startPosition;
}

BezierToForward* BezierToForward::reverse() const
{
    CCASSERT(false, "CCBezierTo doesn't support the 'reverse' method");
    return nullptr;
}